﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Summerset.Isbndb.Categories
{

    /// <summary>
    /// The 'categories' collection provides information about the category structure used by ISBNdb.com. 
    /// Categories form a hierarchical structure by referring to their parents -- see 'parent_id' attribute below.
    /// Most categories list subjects, some list authors and publishers (alphabetical categories currently), 
    /// some list books (book shelves categories that organize books by DDC or LCC numbers).
    /// Categories do not list items contained in them -- instead, items (subjects, authors, publishers) list categories they belong to.    
    /// </summary>
    public static class CategoriesArgs
    {


        /// <summary>
        /// Gets an array of strings containing the valid indexes for the categories collection.
        /// </summary>
        public static string[] GetValidIndexArguments()
        {

            return typeof(Arguments)
                .GetFields(BindingFlags.Public | BindingFlags.Static)
                .Select(fi => fi.GetRawConstantValue().ToString())
                .ToArray();

        }

        /// <summary>
        /// Gets an array of strings that contain the additional results that can be requested from the categories collection.
        /// </summary> 
        public static string[] GetValidResultArguments()
        {

            return typeof(Results)
                .GetFields(BindingFlags.Public | BindingFlags.Static)
                .Select(fi => fi.GetRawConstantValue().ToString())
                .ToArray();

        }

        /// <summary>
        /// Contains all valid arguments for index1 of the categories collection.
        /// </summary>
        public static class Arguments
        {

            /// <summary>
            /// Performs a search on the category name
            /// </summary>
            /// <remarks>
            /// The search is performed on the category full path -- names of all its parent categories combined with the name of the final category.
            /// The search follows the same rules and syntax as the search on the website itself -- you can group words together using double quotes, 
            /// all non-ignored words must be present in the results.
            /// </remarks>
            public const string name = "name";

            /// <summary>
            /// Retrieving category data by ISBNdb.com's category ID. Returns at most one match.
            /// </summary>
            public const string category_id = "category_id";

            /// <summary>
            /// Retrieving the list of categories that are contained inside the given category. 
            /// By specifying an empty parent category ID you can get a list of top-level categories.
            /// </summary>
            public const string parent_id = "parent_id";
        }

        /// <summary>
        /// Contains all the valid additional result field arguments for the categories collection.
        /// </summary>
        public static class Results
        {
            /// <summary>
            /// Shows more details about category.
            /// </summary>
            public const string details = "details";

            /// <summary>
            /// Shows subcategories for each category found.
            /// </summary>
            public const string subcategories = "subcategories";
        }

    }
}
